#ifndef NAMEGIVERENGINE_H
#define NAMEGIVERENGINE_H

#include "engine.h"
#include "../namegiver.h"

class NameGiverEngine: public Engine
{
public:
  static const char* ARG_RACE;
  static const char* ARG_CREATION_POINTS;
  static const int ARG_CREATION_POINTS_DEFAULT;
  static const char* ARG_LEGEND_POINTS;
  static const int ARG_LEGEND_POINTS_DEFAULT;
  static const char* ARG_MAX_LANGUAGES;
  // TODO
  static const int ARG_MAX_LANGUAGES_DEFAULT;

  static const char* ARG_RAISE_KNOWN_SKILL_PROBABILITY;
  static const double ARG_RAISE_KNOWN_SKILL_PROBABILITY_DEFAULT;
  static const char* ARG_LEARN_NEW_SKILL_PROBABILITY;
  static const double ARG_LEARN_NEW_SKILL_PROBABILITY_DEFAULT;
  // This is only effective if we previously chose to raise a skill.
  static const char* ARG_PRIME_SKILLS;
  static const char* ARG_RAISE_PRIME_SKILL_PROBABILITY;
  static const double ARG_RAISE_PRIME_SKILL_PROBABILITY_DEFAULT;


  static const char* ARG_RAISE_ATTRIBUTE_PROBABILITY;
  static const double ARG_RAISE_ATTRIBUTE_PROBABILITY_DEFAULT;
  // This is only effective if we previously chose to raise an attribute.
  static const char* ARG_PRIME_ATTRIBUTES;
  static const char* ARG_RAISE_PRIME_ATTRIBUTE_PROBABILITY;
  static const double ARG_RAISE_PRIME_ATTRIBUTE_PROBABILITY_DEFAULT;

  NameGiverEngine();

protected:
  NameGiver* _nameGiver;

  virtual void init(const QVariantMap &args);
  virtual void start();
  virtual void reset();

  virtual void createBase();

  virtual void refreshLists();
  virtual bool canSpendLegendPoints();
  virtual void spendLegendPoints();

private:
  int _creationPoints;
  int _legendPoints;
  int _maxLanguages;

  QList<ed::Attribute> _primeAttributes;
  QList<ed::Attribute> _otherAttributes;
  QList<Skill> _primeSkills;
  QList<Skill> _otherSkills;

  double _raiseKnownSkillProbability;
  double _learnNewSkillProbability;
  double _raisePrimeSkillProbability;

  double _raiseAttributeProbability;
  double _raisePrimeAttributeProbability;

  void createBaseAttributes();
  void raiseAttribute();

  void createBaseSkills();
  int learnNewSkill(const Skill &s);
  int raiseSkill(const Skill& s);

  QMap<ed::Attribute,int> _attributeAugmentations;
  QList<Skill> _knownPrimeSkills;
  QList<Skill> _knownOtherSkills;
};

#endif // NAMEGIVERENGINE_H
